#include "DemoContainerCommon.h"
#include "DemoContainer.h"

#include "DemoContainerUnitTestAll.h"

DemoContainerSuiteDriverAllTest::DemoContainerSuiteDriverAllTest()
{
  char tmpData[FOUR*2];
  std::string str;
  for ( int i = 0; i < MAXVALUE; i++ )
  {

#ifdef _MSC_VER
    sprintf_s(tmpData, FOUR*2, "%d", i);
#else
    sprintf(tmpData, "%d", i);
#endif

    str = std::string(tmpData);
    str += TESTSTRFALG;
    uintTestData_.insert(std::map<int, std::string>::value_type(i, str));
  }
}                                                          

TEST_P(DemoContainerStubAllTest, AllTestDataOne)
{
  DemoContainer container;
  std::string value = GetParam();

  EXPECT_EQ(ZERO, container.get_size());
  EXPECT_EQ(ZERO, container.add_item(value));
  EXPECT_STREQ(value.c_str(), container.get_item(ZERO).c_str());
  EXPECT_EQ(true, container.remove_item(ZERO));
  EXPECT_EQ(ZERO, container.get_size());
}

INSTANTIATE_TEST_CASE_P(AllTestDataOneTest, DemoContainerStubAllTest,
                        testing::Values(
                        "435435n%^%^^&*@#$%^&*(%^&",
                        "1asdfadsf",
                        "1!",
                        "1~@&#(kh",
                        "(dnsduoi:{}",
                        "SDFADSFUNAS'SDIF[PDF",
                        "dslaewnfouewrlkcv;l349879340",
                        "*/*-4987~!@#$",
                        "~!@#$%^&*()_",
                        "546sdf0&*%*SDFHKL",
                        "``1%^&*",
                        "18237",
                        "1234567890",
                        "qqqwert",
                        "rtyuio",
                        "RTYUIO",
                        "&*)6789@#$%FGHJKTYUIO",
                        "~!@#$%^&*()~!@#$%^&*()!@#$%^&*WERTYUISDFGHJCVBNMGHJTYUI",
                        "QWERTYUIOP{?><MNBNCASDFGHJWERTYUI",
                        "QWERTYUIOP{ASDFGHJKXCVBNM<~!@#$%^&*()`123456789QWERTYUIOP{ASDFGHJKXCVBNM<~!@#$%^&*()`123456789QWERTYUIOP{ASDFGHJKXCVBNM<~!@#$%^&*()`123456789QWERTYUIOP{ASDFGHJKXCVBNM<~!@#$%^&*()`123456789QWERTYUIOP{ASDFGHJKXCVBNM<~!@#$%^&*()`123456789",
                        "!@#$~QWAZXCSEWRFFHBYHO/*-+-/-*/-*/-*/-FIIT",
                        "123268463284",
                        "ewreworueworkjbkdshfoidsfsdjflsdfjoueir",
                        "ORUOEWREWRHPSDOUCNZXLCKASWDEPQWUEROIEYRPOEWRUPOWE",
                        "!@#$%^&*@#$%^&*$%^&*%^&*$%^&*$%^&$%^&*$%^&*$%^&*$%^&*(@#$%^&*()#$%^&*"
                        "qwertyuEWERTYUIO!@#$%^&*()1234567890",
                        "%^&*%^&*(34567890456789#$%^&$%^&8456789$%^&*(ughj<RTYUIOVBNM%^&*",
                        "ADHF-345324-5982PDJFPOADFAF6546%*(^(&*)*&*^$&^GFGjhsdfljaosdupdshfsd[][..;'l;",
                        "fadsf2354-752542=592dfgjsdklgmnewrltjrposdflgnks;lkj68765156*%*(&()*(+^%&*^()&)(_",
                        "dsfasdk234%*(&_)JKJGLLJNJL:JYUOGkjerlewirpohfdoasf08-0893423^(*(&_)(+_*%(*&&()**%^&&%(*&(^()&_HKHJTGUIYKYOUI",
                        "dfs",
                        "asdfasdf34570923578KHLPOUIPOIJUO546790@#$%^&*$%^&*",
                        "sdfdhf234023754398dlkfHPKHLJHkl>?:{}",
                        "564968466134867943613135476843616546465",
                        "@#$%^&3$%^&*$%^&*34567834567899234567894567893456ERTYUIDFGHJVBNFG{:>}?}?FGHJK",
                        "dsfasdf234293473274097GHLJHKHFIF^(*&^(*^(*^*(^",
                        "dfedsfds45643156456345278395742954*()&*(LHKLBN:J:LJUO()^*&()^*&*)^(&*^",
                        "JHEWRIHUW&^()&()#$%^$%^&*JHGSDGAISDASODUS)(&*&^()^&*(",
                        "JHEWRIHUW&^()&()#$%^$%^&*JHGSDGAISDASODUS)(&*&^()^&*(JHEWRIHUW&^()&()#$%^$%^&*JHGSDGAISDASODUS)(&*&^()^&*(JHEWRIHUW&^()&()#$%^$%^&*JHGSDGAISDASODUS)(&*&^()^&*(JHEWRIHUW&^()&()#$%^$%^&*JHGSDGAISDASODUS)(&*&^()^&*(JHEWRIHUW&^()&()#$%^$%^&*JHGSDGAISDASODUS)(&*&^()^&*(JHEWRIHUW&^()&()#$%^$%^&*JHGSDGAISDASODUS)(&*&^()^&*(",
                        "dsfadsf&)(^*(&*^*(&^JHJHDSFLBASFKL45678567867$%&*%^&*%^&*^&",
                        "asdfdds7984316876834534654kghgpoeuferhnJNKDGFD:SJFL>:>{}:L:",
                        "23456789345787654378976543567896543678356789546783567843782",
                        "ffkdsf;dasnf;askJHDNFLDASJF*&)#()$#$&#(@&$(#){:>}?",
                        "123",
                        "987",
                        "QW<>?",
                        "Asdfads%^&(*&",
                        "Bsdfasdf&*(",
                        "Csdfsd^*^&&*",
                        "D23789789&*(&*(",
                        "Dasdfasdf"
                        ));

TEST_F(DemoContainerSuiteDriverAllTest, AllTestDataMultData)
{
  DemoContainer container;
  std::map<int, std::string> tmpData = this->get_usedata();

  EXPECT_EQ(ZERO, container.get_size());
  EXPECT_ANY_THROW( container.get_item( ZERO ) );
  EXPECT_FALSE(container.remove_item(ZERO));

  for ( int i = 0; i < FIFTY; i++ )
  {
    EXPECT_EQ(i, container.add_item( tmpData[i] ));
    EXPECT_EQ(i+1, container.get_size());
  }

  for ( int i = 0; i < FIFTY; i++ )
  {
    EXPECT_STREQ(tmpData[i].c_str(), container.get_item(i).c_str());
    EXPECT_EQ(FIFTY, container.get_size());
  }

  for ( int i = 0; i < FIFTY; i++ )
  {
    EXPECT_TRUE(container.remove_item(ZERO));
    EXPECT_EQ(FIFTY - i - 1, container.get_size());
  }
}

TEST_F(DemoContainerSuiteDriverAllTest, AllTestDataLargeNumData)
{
  std::cout << std::endl << "It will run a large of data, please wait" << std::endl;

  DemoContainer container;
  std::map<int, std::string> tmpData = this->get_usedata();

  EXPECT_EQ(ZERO, container.get_size());
  EXPECT_ANY_THROW( container.get_item( ZERO ) );
  EXPECT_FALSE(container.remove_item(ZERO));

  for ( int i = 0; i < MAXVALUE; i++ )
  {
    EXPECT_EQ(i, container.add_item( tmpData[i] ));
    EXPECT_EQ(i+1, container.get_size());
  }

  for ( int i = 0; i < MAXVALUE; i++ )
  {
    EXPECT_STREQ(tmpData[i].c_str(), container.get_item(i).c_str());
    EXPECT_EQ(MAXVALUE, container.get_size());
  }

  for ( int i = 0; i < MAXVALUE; i++ )
  {
    EXPECT_TRUE(container.remove_item(ZERO));
    EXPECT_EQ(MAXVALUE - i - 1, container.get_size());
  }
}
